<%--
功能：显示库存信息
--%>
<%@ tag pageEncoding="UTF-8"%>
<%@tag import="com.probiz.estore.core.util.ContextUtil"%>
<%@tag import="com.probiz.estore.common.service.InventoryService"%>
<%@tag import="com.probiz.estore.common.model.inventory.Inventory"%>
<%@tag import="com.probiz.estore.common.util.DateUtil"%>
<%@tag import="com.probiz.estore.core.util.I18nUtil"%>
<%@tag import="com.probiz.estore.inventory.service.InventoryManager"%>
<%@tag import="com.probiz.estore.common.model.inventory.SkuInventoryVO"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ attribute name="buyCount" required="true" type="java.lang.Integer"
	description="购买了的数量"%>
<%@ attribute name="productSku" required="true"
	type="com.probiz.estore.common.model.catalog.ProductSku"%>
<%
String msg=null;
InventoryManager inventoryManager=(InventoryManager)ContextUtil.getSpringBeanById("inventoryManager");
SkuInventoryVO skuInventoryVO=inventoryManager.getSkuInventoryVO(productSku);
if(skuInventoryVO.getType().intValue()==4){
	//--如果该商品是无限库存，不受库存管理
	msg=I18nUtil.getInstance().getMessage("productSku.inventory.in.stock");
}else if(skuInventoryVO.getType().intValue()==5){
	//--否则如果该商品是预订且不受预定数量限制 
	if(skuInventoryVO.getAvailableQuantity()>=buyCount){
		msg=I18nUtil.getInstance().getMessage("productSku.inventory.in.stock");	
	}else{
		if(skuInventoryVO.getExpectedRestockDate()==null){
			//--如果有设定再进货时间
			if(skuInventoryVO.getAvailabilityRule().intValue()==2){
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.preOrder.noDate");
			}else{
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.backOrder.noDate");
			}
		}else{
			if(skuInventoryVO.getAvailabilityRule().intValue()==2){
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.preOrder",new Object[]{DateUtil.convertDateToString(skuInventoryVO.getExpectedRestockDate())});
			}else{
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.backOrder",new Object[]{DateUtil.convertDateToString(skuInventoryVO.getExpectedRestockDate())});
			}
		}
	}
}else if(skuInventoryVO.getType().intValue()==2){
	//--否则如果该商品是预订但有预定数量限制
	if(skuInventoryVO.getAvailableQuantity()>=buyCount){
		msg=I18nUtil.getInstance().getMessage("productSku.inventory.in.stock");	
	}else{
		if(skuInventoryVO.getExpectedRestockDate()==null){
			//--如果有设定再进货时间
			if(skuInventoryVO.getAvailabilityRule().intValue()==2){
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.preOrder.noDate");
			}else{
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.backOrder.noDate");
			}
		}else{
			if(skuInventoryVO.getAvailabilityRule().intValue()==2){
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.preOrder",new Object[]{DateUtil.convertDateToString(skuInventoryVO.getExpectedRestockDate())});
			}else{
				msg=I18nUtil.getInstance().getMessage("productSku.inventory.on.backOrder",new Object[]{DateUtil.convertDateToString(skuInventoryVO.getExpectedRestockDate())});
			}
		}
	}
}else if(skuInventoryVO.getType().intValue()==1&&skuInventoryVO.getAvailableQuantity()>=buyCount){
	//--否则如果该商品是有库存才可售且购买数量少于可出售的数量
	msg=I18nUtil.getInstance().getMessage("productSku.inventory.in.stock");
}
if(msg==null){
	msg=I18nUtil.getInstance().getMessage("productSku.inventory.outof.stock");
}
out.print(msg);
%>